package com.ruoyi.work.controller;

import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.resumes.domain.Resumes;
import com.ruoyi.system.domain.Applications;
import com.ruoyi.system.domain.Companyinfo;
import com.ruoyi.system.service.IApplicationsService;
import com.ruoyi.system.service.ICompanyinfoService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.work.mapper.JobbasicinfoMapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.work.domain.Jobbasicinfo;
import com.ruoyi.work.service.IJobbasicinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 岗位job管理Controller
 *
 * @author ruoyi
 * @date 2024-11-10
 */
@RestController
@RequestMapping("/work/jobbasicinfo")
public class JobbasicinfoController extends BaseController
{
    @Autowired
    private IJobbasicinfoService jobbasicinfoService;
    @Autowired
    private ISysUserService iSysUserService;
    @Autowired
    private IApplicationsService iApplicationsService;
    @Autowired
    private ICompanyinfoService iCompanyinfoService;

    @Autowired
    private JobbasicinfoMapper jobbasicinfoMapper;


    /**
     * 查询岗位job管理列表
     */
    @PreAuthorize("@ss.hasPermi('work:jobbasicinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(Jobbasicinfo jobbasicinfo)
    {
        startPage();
        List<Jobbasicinfo> list = jobbasicinfoService.selectJobbasicinfoList(jobbasicinfo);
        return getDataTable(list);
    }

    /**
     * 导出岗位job管理列表
     */
    @PreAuthorize("@ss.hasPermi('work:jobbasicinfo:export')")
    @Log(title = "岗位job管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Jobbasicinfo jobbasicinfo)
    {
        List<Jobbasicinfo> list = jobbasicinfoService.selectJobbasicinfoList(jobbasicinfo);
        ExcelUtil<Jobbasicinfo> util = new ExcelUtil<Jobbasicinfo>(Jobbasicinfo.class);
        util.exportExcel(response, list, "岗位job管理数据");
    }

    /**
     * 获取岗位job管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:jobbasicinfo:query')")
    @GetMapping(value = "/{jobId}")
    public AjaxResult getInfo(@PathVariable("jobId") Long jobId)
    {
        return success(jobbasicinfoService.selectJobbasicinfoByJobId(jobId));
    }

    /**
     * 新增岗位job管理
     */
    @PreAuthorize("@ss.hasPermi('work:jobbasicinfo:add')")
    @Log(title = "岗位job管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Jobbasicinfo jobbasicinfo)
    {
        return toAjax(jobbasicinfoService.insertJobbasicinfo(jobbasicinfo));
    }

    /**
     * 修改岗位job管理
     */
    @PreAuthorize("@ss.hasPermi('work:jobbasicinfo:edit')")
    @Log(title = "岗位job管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Jobbasicinfo jobbasicinfo)
    {
        return toAjax(jobbasicinfoService.updateJobbasicinfo(jobbasicinfo));
    }

    /**
     * 删除岗位job管理
     */
    @PreAuthorize("@ss.hasPermi('work:jobbasicinfo:remove')")
    @Log(title = "岗位job管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jobIds}")
    public AjaxResult remove(@PathVariable Long[] jobIds)
    {
        return toAjax(jobbasicinfoService.deleteJobbasicinfoByJobIds(jobIds));
    }

    /**
     * 新增投递信息
     */
//    @PreAuthorize("@ss.hasPermi('work:jobbasicinfo:add2')")
//    @Log(title = "投递记录", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add2(@RequestBody Applications jobbasicinfo)
//    {
////        Long jobid=jobbasicinfo.getJobId();
////        Applications applications= iApplicationsService.selectApplicationByjobid(jobid);
////        SysUser sysUser=iSysUserService.selectUserByUserName(jobbasicinfo.getUsername());
////        applications.setUserId(sysUser.getUserId());
////        applications.setJobId(jobbasicinfo.getJobId());
//
//        return toAjax(jobbasicinfoService.insertApplications(jobbasicinfo));
//    }
    @PreAuthorize("@ss.hasPermi('collection:collection:list')")
    @GetMapping("/listCollection")
    public TableDataInfo getCollection(Jobbasicinfo jobbasicinfo)
    {
        List<Jobbasicinfo> list = jobbasicinfoService.selectCollections(jobbasicinfo);
        return pagination(list);
    }

}
